#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2016-12-06 21:13:55
# @Author  : guoben (guoben.ly@qq.com)
# @Link    : https://git.oschina.net/guoben

import urllib
import re
import datetime


URL = 'http://www.toutiao.com/a6361943236148216066/'

if __name__ == "__main__":
    html = urllib.urlopen(URL)
    doc = html.read()
    pat = re.compile(r'<img src=\"(http://.*?)\"')
    url_list = pat.findall(doc)
    for img in url_list:
        name = datetime.datetime.now().strftime('%Y%m%d-%H%M%S-%f')
        print urllib.urlretrieve(img, name + '.gif')
